/**
 * 初始化交易流水详情对话框
 */
var TransHistoryInfoDlg = {
    transHistoryInfoData : {}
};

/**
 * 清除数据
 */
TransHistoryInfoDlg.clearData = function() {
    this.transHistoryInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TransHistoryInfoDlg.set = function(key, val) {
    this.transHistoryInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TransHistoryInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
TransHistoryInfoDlg.close = function() {
    parent.layer.close(window.parent.TransHistory.layerIndex);
}

/**
 * 收集数据
 */
TransHistoryInfoDlg.collectData = function() {
    this
    .set('id')
    .set('mchNo')
    .set('mchName')
    .set('merCode')
    .set('chMerCode')
    .set('orderCode')
    .set('platOrderCode')
    .set('orderTime')
    .set('orderAmount')
    .set('settleType')
    .set('busCode')
    .set('realName')
    .set('idCard')
    .set('accNo')
    .set('mobile')
    .set('frontUrl')
    .set('callBackUrl')
    .set('tranTime')
    .set('chSerialNo')
    .set('drawFee')
    .set('tradeRate')
    .set('tradeFee')
    .set('actualAmount')
    .set('tranStatus')
    .set('drawStatus')
    .set('drawAmount')
    .set('resCode')
    .set('resMsg')
    .set('createTime')
    .set('updateTime');
}

/**
 * 提交添加
 */
TransHistoryInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/transHistory/add", function(data){
        Feng.success("添加成功!");
        window.parent.TransHistory.table.refresh();
        TransHistoryInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.transHistoryInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
TransHistoryInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/transHistory/update", function(data){
        Feng.success("修改成功!");
        window.parent.TransHistory.table.refresh();
        TransHistoryInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.transHistoryInfoData);
    ajax.start();
}

$(function() {

});
